﻿@using FCZLM.Core.Models
@model IEnumerable<FCZLM.Core.Models.OrderDetails>
@{
    ViewData["Title"] = "订单详细列表页";
    var OrdersRepository = ViewBag._OrdersRepository as List<Orders>;
    Layout = null;
}
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <div>
        <div class="demoTable layui-form">

            <div class="layui-inline">
                <select id="OrderId">
                    <option value="0">请选择订单ID</option>
                    @foreach (var item in OrdersRepository)
                    {
                        <option value="@item.Id">@item.Id</option>
                    }
                </select>
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
            
        </div>

    </div>

    <table class="layui-hide" id="test"></table>


    <script src="/layui//layui.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

    <script>
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#test'
                , url: '/forderdetail/index'
                , page: true//开启分页
                , method: "post"
                , height: 312
                //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                , cols: [[
                    { field: 'id', title: 'ID', width: 50, sort: true, fixed: 'left' }
                    , { field: 'orderId', title: '订单Id', width: 100, sort: true }
                    , { field: 'productId', title: '商品', width: 200 }
                    , { field: 'price', title: '单价', width: 100 }
                    , { field: 'num', title: '数量', width: 100 }
                    , { field: 'remark', title: '说明', width: 250 }
                    , { field: 'createTime', title: '订单时间', width: 180, sort: true }
                   
                ]],
                initSort: {
                    field: 'id'
                    , type: 'desc'
                },
                id: "newsList"
            });
            var $ = layui.$, active = {
                reload: function () {

                    var NewsCategoryIdinput = $("#OrderId");
                    //执行重载
                    table.reload('newsList', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                        , where: {

                            OrderId: NewsCategoryIdinput.val()
                        }
                    });
                }
            };
            $('.demoTable .layui-btn').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>
</html>
